﻿<UserControl x:Class="ReflectionStudio.Components.UserControls.VisualView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:my="http://schemas.microsoft.com/wpf/2008/toolkit"             
    xmlns:project="clr-namespace:ReflectionStudio.Core.Project;assembly=ReflectionStudio.Core">
    <UserControl.Resources>
        
        <DataTemplate x:Key="AssemblyItemTemplate" DataType="{x:Type project:CallStackInfoAgregated}">
		
		<Border CornerRadius="2" BorderThickness="1" BorderBrush="Black" Margin="5" Padding="0"
                HorizontalAlignment="Stretch">
			<Grid Margin="5">
                <Grid.RowDefinitions>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
				<Border >
					<Border.Background>
						<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
							<GradientStop Color="Black" Offset="0"/>
							<GradientStop Color="White" Offset="1"/>
						</LinearGradientBrush>
					</Border.Background>
                </Border>
                    <Image Grid.Row="0" Source="/ReflectionStudio;component/Resources/Images/16x16/application/save.png" Margin="3" HorizontalAlignment="Left"/>
                <TextBlock Grid.Row="0" Text="{Binding MethodName}" FontWeight="Bold"/>				
            <Grid Grid.Row="1">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="*"/>
					<RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <TextBlock Grid.ColumnSpan="2" Text="{Binding Namespace}" />
				
                <TextBlock Grid.Column="0" Grid.Row="1" Text="Time" />
                <TextBlock Grid.Column="1" Grid.Row="1" Text="{Binding TotalTick}" />
				
                <TextBlock Grid.Column="0" Grid.Row="2" Text="Call" />
                <TextBlock Grid.Column="1" Grid.Row="2" Text="{Binding CallCount}" />

                <TextBlock Grid.Column="0" Grid.Row="3" Text="Avg." />
                <TextBlock Grid.Column="1" Grid.Row="3" Text="{Binding AverageTick}" />
				
				<ProgressBar Grid.ColumnSpan="2" Grid.Row="4" Height="16" Value="{Binding TotalTick}" />

            </Grid>
            </Grid>			
			</Border>
			
        </DataTemplate>
        
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <TextBlock Grid.Column="0" Grid.Row="0">Before</TextBlock>
        <TextBlock Grid.Column="1" Grid.Row="0">Curent</TextBlock>
        <TextBlock Grid.Column="2" Grid.Row="0">After</TextBlock>
        <ScrollViewer Grid.Row="1" Grid.ColumnSpan="3"
                      VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" >
            <Grid>                
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <ListBox Grid.Column="0"
                     ItemsSource="{Binding CallstackAgBefore}"
                     ItemTemplate="{StaticResource AssemblyItemTemplate}"
                     IsSynchronizedWithCurrentItem="False" Name="ListBefore"
                     SelectionChanged="ListBefore_SelectionChanged"
                     MouseDoubleClick="ListBefore_MouseDoubleClick">
                </ListBox>
                <ListBox Grid.Column="1"
                    ItemsSource="{Binding CurrentAgreg}"
                    ItemTemplate="{StaticResource AssemblyItemTemplate}"
                    Name="ListCurrent" SelectionChanged="ListCurrent_SelectionChanged">
                </ListBox>
                <ListBox Grid.Column="2"
                    ItemsSource="{Binding CallstackAgAfter}"     
                    ItemTemplate="{StaticResource AssemblyItemTemplate}"
                    IsSynchronizedWithCurrentItem="False" Name="ListAfter"
                    SelectionChanged="ListAfter_SelectionChanged" MouseDoubleClick="ListAfter_MouseDoubleClick">
                </ListBox>
            </Grid>
        </ScrollViewer>
    </Grid>
</UserControl>
